﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="产品入出库台账.aspx.cs" Inherits="syc.Store.产品入出库台账" %>
<html>
<head>
<title></title>
</head>
<body>
<script type="text/javascript" language="javascript" src="/common.js"></script>
<form id="form1" runat="server">
<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
    ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>" 
    SelectCommand="SELECT 0 as [ID], '全部' as [名称] UNION SELECT [ID], [名称] FROM [原料供货单位]"></asp:SqlDataSource>

<asp:SqlDataSource ID="SqlDataSource2" runat="server" 
    ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>" 
    SelectCommand="SELECT 0 as [ID], '全部' as [名称] UNION SELECT [ID], [名称] FROM [产品订货单位]"></asp:SqlDataSource>
    

<div id="wintop" class="wintop">产品入出库台账</div>
<asp:Panel ID="Panel1" runat="server" GroupingText="台账查询" CssClass="panel">
<asp:SqlDataSource ID="DS_ChanPin" runat="server" 
    ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>" 
    SelectCommand="SELECT [ID],[品名]+' '+[钢级]+' '+[规格] AS 名称 FROM [产品]"></asp:SqlDataSource>
产品类别：<asp:DropDownList ID="ChanPin" runat="server" Width="150px" Font-Size="12px" DataSourceID="DS_ChanPin" DataTextField="名称" DataValueField="ID">

</asp:DropDownList>  
<span style="margin-left:30px"></span>
生产单位：<asp:DropDownList ID="FenChang" runat="server" Width="136px">
    <asp:ListItem Value="101">一分厂</asp:ListItem>
    <asp:ListItem Value="201">二分厂B1</asp:ListItem>
    <asp:ListItem Value="202">二分厂B2</asp:ListItem>
    <asp:ListItem Value="501">五分厂C1</asp:ListItem>
    <asp:ListItem Value="502">五分厂C2</asp:ListItem>
</asp:DropDownList> 

<span style="margin-left:30px"></span>
Excel选项：<asp:DropDownList ID="JiOu" runat="server" Width="120px">
    <asp:ListItem Value="1">选择奇数页</asp:ListItem>
    <asp:ListItem Value="2">选择偶数页</asp:ListItem>
</asp:DropDownList> 

<div style="height:5px;line-height:5px;"></div>

起始序号：<asp:TextBox ID="XuHao1" runat="server" CssClass="intxt1" Width="136px"></asp:TextBox>
<span style="margin-left:30px"></span>
截止序号：<asp:TextBox ID="XuHao2" runat="server" CssClass="intxt1" Width="136px"></asp:TextBox>


<span style="margin-left:30px"></span>
<asp:Button ID="Button_Query" runat="server" Text="查 询" CssClass="mbutton" onclick="Button_Query_Click"
    UseSubmitBehavior="False" />
<asp:Button ID="Button_Export" runat="server" Text="导出Excel" CssClass="mbutton" 
        UseSubmitBehavior="False" OnClick="Button_Export_Click"/>
<asp:Button ID="Button_Advanced" runat="server" Text="高级选项" CssClass="mbutton" 
        UseSubmitBehavior="False" onclick="Button_Advanced_Click" />

<asp:Panel ID="Panel2" runat="server" Visible="false">
<hr />
原料供货：<asp:DropDownList ID="GongHuo" runat="server" 
    DataSourceID="SqlDataSource1" DataTextField="名称" DataValueField="ID" Width="136px">
</asp:DropDownList>
<span style="margin-left:30px"></span>
订货单位：<asp:DropDownList ID="DingHuo" runat="server" 
    DataSourceID="SqlDataSource2" DataTextField="名称" DataValueField="ID" Width="136px">
</asp:DropDownList>
<div style="height:1px;line-height:1px;"></div>
起始捆号：<asp:TextBox ID="KunHao1" runat="server" CssClass="intxt1" Width="136px"></asp:TextBox>
<span style="margin-left:30px"></span>
截止捆号：<asp:TextBox ID="KunHao2" runat="server" CssClass="intxt1" Width="136px"></asp:TextBox>

<div style="height:1px;line-height:1px;"></div>
入库日期：<asp:TextBox ID="Date1" runat="server" CssClass="intxt1" Width="120px"></asp:TextBox><img alt="" src="/Icons/29.png" align="middle" onclick="makecalendar(document.getElementById('Date1').value, document.getElementById('Date1'));" />
<span style="margin:0px 40px 0px 39px">至</span>
<asp:TextBox ID="Date2" runat="server" CssClass="intxt1" Width="120px"></asp:TextBox><img alt="" src="/Icons/29.png" align="middle" onclick="makecalendar(document.getElementById('Date2').value, document.getElementById('Date2'));" />
<br />
出库日期：<asp:TextBox ID="Date3" runat="server" CssClass="intxt1" Width="120px"></asp:TextBox><img alt="" src="/Icons/29.png" align="middle" onclick="makecalendar(document.getElementById('Date3').value, document.getElementById('Date3'));" />
<span style="margin:0px 40px 0px 39px">至</span>
<asp:TextBox ID="Date4" runat="server" CssClass="intxt1" Width="120px"></asp:TextBox><img alt="" src="/Icons/29.png" align="middle" onclick="makecalendar(document.getElementById('Date4').value, document.getElementById('Date4'));" />
</asp:Panel>
</asp:Panel>

<style>td.grid{cursor:default;}</style>
<div class="gridframe">
    <div class="gridview">
    
        <table border="1" width="100%" cellspacing="0" cellpadding="0" bordercolor="#e5cfab">
            <tr>
	            <td class="grid-title">产品入出库台账</td>
	        </tr>
	        <tr>
	            <td class="grid-back">
                    <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
                        ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>" 
                        onselected="SqlDataSource1_Selected" ></asp:SqlDataSource>
                    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
                        AutoGenerateColumns="False" CssClass="grid" DataKeyNames="ID" 
                        DataSourceID="SqlDataSource3" 
                        GridLines="None" ondatabound="GridView1_DataBound" 
                        onpageindexchanged="GridView1_PageIndexChanged" AllowSorting="True" 
                        UseAccessibleHeader="False"  PageSize="20" >
                        <PagerSettings Visible="False" />
                        <RowStyle CssClass="grid-row-normal" />
                        <Columns>
                        
                           <asp:TemplateField HeaderText="原料供货单位" SortExpression="原料供货单位">
                                <ItemTemplate>
                                    <asp:Label ID="Label1" runat="server" Text='<%# Eval("原料供货单位") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="120px" />
                            </asp:TemplateField>
                            
                           <asp:TemplateField HeaderText="入库序号" SortExpression="入库序号">
                                <ItemTemplate>
                                    <asp:Label ID="Label2" runat="server" Text='<%# Eval("入库序号") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="80px" />
                            </asp:TemplateField>
                            
                            <asp:TemplateField HeaderText="入库日期" SortExpression="入库日期">
                                <ItemTemplate>
                                    <asp:Label ID="Label3" runat="server" Text='<%# Eval("入库日期","{0:d}") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="80px" />
                            </asp:TemplateField>  
                            
                            <asp:TemplateField HeaderText="炉号" SortExpression="炉号">
                                <ItemTemplate>
                                    <asp:Label ID="Label4" runat="server" Text='<%# Eval("炉号") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="80px" />
                            </asp:TemplateField>  

                            <asp:TemplateField HeaderText="支数" SortExpression="支数">
                                <ItemTemplate>
                                    <asp:Label ID="Label5" runat="server" Text='<%# Eval("支数") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="36px" />
                            </asp:TemplateField>
                            
                            <asp:TemplateField HeaderText="捆编号" SortExpression="捆号">
                                <ItemTemplate>
                                    <asp:Label ID="Label6" runat="server" Text='<%# Eval("捆编号") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="90px" />
                            </asp:TemplateField>
                            
                            <asp:TemplateField HeaderText="捆重量(kg)" SortExpression="捆重量">
                                <ItemTemplate>
                                    <asp:Label ID="Label7" runat="server" Text='<%# Eval("重量") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="70px" />
                            </asp:TemplateField>

                            <asp:TemplateField HeaderText="捆长度(m)" SortExpression="长度">
                                <ItemTemplate>
                                    <asp:Label ID="Label8" runat="server" Text='<%# Eval("长度") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="70px" />
                            </asp:TemplateField>
                            
                            <asp:TemplateField HeaderText="生产日期" SortExpression="生产日期">
                                <ItemTemplate>
                                    <asp:Label ID="Label9" runat="server" Text='<%# Eval("生产日期","{0:d}") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="80px" />
                            </asp:TemplateField> 
                            
                            <asp:TemplateField HeaderText="库区" SortExpression="库区">
                                <ItemTemplate>
                                    <asp:Label ID="Label10" runat="server" Text='<%# Eval("库区") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="36px" />
                            </asp:TemplateField>

                            <asp:TemplateField HeaderText="出库日期" SortExpression="出库日期">
                                <ItemTemplate>
                                    <asp:Label ID="Label11" runat="server" Text='<%# Eval("出库日期","{0:d}") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="80px" />
                            </asp:TemplateField> 
                            
                            <asp:TemplateField HeaderText="发运方式" SortExpression="运输方式">
                                <ItemTemplate>
                                    <asp:Label ID="Label12" runat="server" Text='<%# Eval("运输方式") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="80px" />
                            </asp:TemplateField> 
                            
                            <asp:TemplateField HeaderText="出库序号" SortExpression="出库序号">
                                <ItemTemplate>
                                    <asp:Label ID="Label13" runat="server" Text='<%# Bind("出库序号") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="80px" />
                            </asp:TemplateField> 
                            
                        </Columns>
                        <SelectedRowStyle CssClass="grid-row-selected" />
                      </asp:GridView>
	            </td>
            </tr>
            <tr>
	            <td>   
	                <table width="100%">
	                    <tr>
	                        <td class="pagebar">
                                <asp:Button ID="Button_Pager_First" UseSubmitBehavior="false" runat="server" Text="" ToolTip="首页" 
                                    CssClass="pageturn-first-b" onclick="Pager_Click" CommandName="--" />
                                <asp:Button ID="Button_Pager_Prev" UseSubmitBehavior="false" runat="server" Text="" ToolTip="上一页" 
                                    CssClass="pageturn-prev-b" onclick="Pager_Click" CommandName="-" />
                                <input type="button" class="page-split" UseSubmitBehavior="false" disabled />第<asp:TextBox 
                                    ID="TextBox_Pager" AutoPostBack="True" runat="server" CssClass="pageturn" 
                                    ontextchanged="Pager_Click"></asp:TextBox>页<input type="button" class="page-split" disabled /><asp:Label ID="Label_Pages" UseSubmitBehavior="false" runat="server"></asp:Label><input type="button" class="page-split" disabled />
                                
                                <asp:Button ID="Button_Pager_Next" UseSubmitBehavior="false" runat="server" Text="" ToolTip="下一页" 
                                    CssClass="pageturn-next-b" onclick="Pager_Click" CommandName="+" />
                                <asp:Button ID="Button_Pager_Last" UseSubmitBehavior="false" runat="server" Text="" ToolTip="末页" 
                                    CssClass="pageturn-last-b" onclick="Pager_Click" CommandName="++" /><asp:Label ID="Label9" runat="server"></asp:Label><input type="button" class="page-split" disabled />
                            </td>
                            <td class="pagebar" align="right">
                                <asp:Label ID="Label_Total" runat="server"></asp:Label>
                            </td>
                        </tr>
                   </table>

	            </td>
            </tr>
        </table>
        

    </div>
</div>

</form>

<script>
var notice = "<%=this.Notice %>";
if (notice != "") {
    parent.showmsgbox(notice);
}
document.onkeydown = function(e) {
    if (!e) e = window.event;
    var tag = e.srcElement;
    if (!tag) tag = e.target;
    if (tag.tagName == "INPUT" && tag.className == "intxt1" || tag.tagName == "SELECT") {
        if (e.keyCode == 13) e.keyCode = 9;
    }
    else if (e.keyCode == 33) {
        document.getElementById("Button_Pager_Prev").click();
    }
    else if (e.keyCode == 34) {
        document.getElementById("Button_Pager_Next").click();
    }
}
document.getElementById("KunHao1").onchange = CheckInput1;
document.getElementById("KunHao2").onchange = CheckInput2;

function CheckInput1()//检测捆号
{
    var errmsg = "“起始捆号”录入有误";
    var t = this.value.replace(/(^ +)|( +$)/, "");
    t = t.replace(/[ \.\*\+\/]+/, "-");
    if (t.search(/[^0-9\-]+/) != -1) {
        parent.showmsgbox(errmsg);
        this.value = "";
        return;
    }
    if (t == "") return;
    t = t.split("-");
    if (t.length != 2) {
        parent.showmsgbox(errmsg);
        return;
    }
    else if (t[0] == '' || t[0].length > 4 || t[1] == '' || t[1].length > 4) {
        parent.showmsgbox(errmsg);
        return;
    }
    if (t[0].length < 4) {
        t[0] = ("000" + t[0]).substr(t[0].length - 1);
    }
    if (t[1].length < 4) {
        t[1] = ("000" + t[1]).substr(t[1].length - 1);
    }
    t[2] = Number(t[1]) + 2000;
    if(t[2]>9999)t[2]=9999;
    t[2] = t[2].toString();
    if (t[2].length < 4) {
        t[2] = ("000" + t[2]).substr(t[2].length - 1);
    }
    this.value = t[0] + "-" + t[1];
    document.getElementById("KunHao2").value = t[0] + "-" + t[2];
}

function CheckInput2()//检测捆号
{
    var errmsg = "“截止捆号”录入有误";
    var t = this.value.replace(/(^ +)|( +$)/, "");
    t = t.replace(/[ \.\*\+\/]+/, "-");
    if (t.search(/[^0-9\-]+/) != -1) {
        parent.showmsgbox(errmsg);
        this.value = "";
        return;
    }
    if (t == "") return;
    t = t.split("-");
    if (t.length != 2) {
        parent.showmsgbox(errmsg);
        return;
    }
    else if (t[0] == '' || t[0].length > 4 || t[1] == '' || t[1].length > 4) {
        parent.showmsgbox(errmsg);
        return;
    }
    if (t[0].length < 4) {
        t[0] = ("000" + t[0]).substr(t[0].length - 1);
    }
    if (t[1].length < 4) {
        t[1] = ("000" + t[1]).substr(t[1].length - 1);
    }
    this.value = t[0] + "-" + t[1];
}

</script>
</body>
</html>
